(function(){

if (!('trim' in String.prototype)) {
  String.prototype.trim = function() {
    var s = this.replace(/^\s+/, '');
    var len = s.length;
    for (var i = s.length - 1; i >= 0; i--) {
      if (/\S/.test(s.charAt(i))) {
        s = s.substring(i+1);
        break;
      }
    }
    
    return s;
  };
}
  
})();
